<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    const obj = { name: 'zs', age: 20 };
    // const { name, age } = obj;
    // console.log('name,age -----> ', name, age);

    // ✅解构时重命名，语法  对象的属性名:变量名
    // const { name: otherName, age } = obj;
    // 原理：const otherName = obj.name
    // console.log('otherName -----> ', otherName);

    // ✅解构时默认值，语法 对象的属性名='默认值'
    // const { name, age = 30, gender = '男' } = obj;
    // console.log('name,age,gender -----> ', name, age, gender);

    // 解构时，换名字和给默认值,工作中不会用到，了解即可
    // const { name: otherName = 10, age, gender: otherGender = 10 } = obj;
    // console.log('otherGender -----> ', otherGender);
  </script>
</html>
